package com.Pawtrack.info.service.impl;

import java.util.List;
import com.Pawtrack.common.utils.DateUtils;
import com.Pawtrack.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.Pawtrack.info.mapper.PetReminderMapper;
import com.Pawtrack.info.domain.PetReminder;
import com.Pawtrack.info.service.IPetReminderService;

/**
 * 宠物提醒Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-14
 */
@Service
public class PetReminderServiceImpl implements IPetReminderService 
{
    @Autowired
    private PetReminderMapper petReminderMapper;

    /**
     * 查询宠物提醒
     * 
     * @param id 宠物提醒主键
     * @return 宠物提醒
     */
    @Override
    public PetReminder selectPetReminderById(String id)
    {
        return petReminderMapper.selectPetReminderById(id);
    }

    /**
     * 查询宠物提醒列表
     * 
     * @param petReminder 宠物提醒
     * @return 宠物提醒
     */
    @Override
    public List<PetReminder> selectPetReminderList(PetReminder petReminder)
    {
        // 自动设置当前用户ID，确保只能查询自己的数据
        if (petReminder != null) {
            petReminder.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        }
        return petReminderMapper.selectPetReminderList(petReminder);
    }

    /**
     * 新增宠物提醒
     * 
     * @param petReminder 宠物提醒
     * @return 结果
     */
    @Override
    public int insertPetReminder(PetReminder petReminder)
    {
        // 自动设置创建人为当前用户ID
        petReminder.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        petReminder.setCreateTime(DateUtils.getNowDate());
        return petReminderMapper.insertPetReminder(petReminder);
    }

    /**
     * 修改宠物提醒
     * 
     * @param petReminder 宠物提醒
     * @return 结果
     */
    @Override
    public int updatePetReminder(PetReminder petReminder)
    {
        // 自动设置更新人为当前用户ID
        petReminder.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
        petReminder.setUpdateTime(DateUtils.getNowDate());
        return petReminderMapper.updatePetReminder(petReminder);
    }

    /**
     * 批量删除宠物提醒
     * 
     * @param ids 需要删除的宠物提醒主键
     * @return 结果
     */
    @Override
    public int deletePetReminderByIds(String[] ids)
    {
        return petReminderMapper.deletePetReminderByIds(ids);
    }

    /**
     * 删除宠物提醒信息
     * 
     * @param id 宠物提醒主键
     * @return 结果
     */
    @Override
    public int deletePetReminderById(String id)
    {
        return petReminderMapper.deletePetReminderById(id);
    }
}